<?php
namespace app\admin\validate;

use think\Validate;

class ArticleValidate extends Validate
{
    protected $rule = [
        'title' => 'require|unique:Article',
        "id" => 'require',
        "sort"=>'require|number',
        "content"=>'require',
        "status" => 'require|in:1,-1',
        "category_id"=>'require'
    ];

    protected $message = [
        'title.require' => '文章标题必须填写',
        'title.unique' => '文章标题重复',
        "id.require" => "缺少id",
        "sort.require"=>"排序必须填写",
        "category_id.require"=>"分类必须选择",
        "sort.number"=>"排序必须是数字",
        "content.require"=>"内容必须填写"
    ];

    protected $scene = [
        'add' => ['title','sort',"content",'category_id'],
        'edit' => ['title','id','sort',"content",'category_id'],
        'status'=>['id','status'],
    ];

}